<?php

require "include/bittorrent.php";
dbconn();
loggedinorreturn();
if ($CURUSER < UC_MODERATOR && $CURUSER['id'] != $betsadmin)
	stderr("错误", "权限不足");
$id = isset($_GET['id']) && is_valid_id($_GET['id']) ? $_GET['id'] : 0;
$bid = isset($_GET['b']) && is_valid_id($_GET['b']) ? $_GET['b'] : 0;
$res = sql_query("SELECT * FROM bets WHERE optionid =" . sqlesc($id) . "")or sqlerr(__FILE__, __LINE__);
if (mysql_num_rows($res) > 0) {
	stderr("错误", "正在试图删除一个已经开始的博彩");
} else {
	sql_query("DELETE FROM betoptions WHERE id =" . sqlesc($id) . "")or sqlerr(__FILE__, __LINE__);
	header("location: bet_opt.php?id=" . $bid . "");
}